using System;

namespace Voodoo.Sauce.Internal.Analytics
{
	public static class AnalyticsUserIdHelper
	{
		private const string PlayerPrefUserIdentifierKey = "VOODOO_ANALYTICS_USER_IDENTIFIER";

		private static string _userId;

		public static string GetUserId()
		{
			if (string.IsNullOrEmpty(_userId))
			{
				_userId = GetStoredUserId();
			}
			return _userId;
		}

		private static string GetStoredUserId()
		{
			if (!NintendoPlayerPrefs.HasKey("VOODOO_ANALYTICS_USER_IDENTIFIER"))
			{
				NintendoPlayerPrefs.SetString("VOODOO_ANALYTICS_USER_IDENTIFIER", Guid.NewGuid().ToString());
			}
			return NintendoPlayerPrefs.GetString("VOODOO_ANALYTICS_USER_IDENTIFIER");
		}
	}
}
